use "dta\LocalNationalWomenOverTime.dta", clear

** Type=1 local councilors
** Type=2 local mayors
** Type=3 Members of parliament 
** Type=4 Cabinet members
** Type=5 List leaders
** Type=6 National candidates

reshape wide fraction_women, i(year) j(type)
*** Share of men in mayoral position subtracted share of men councilors 
gen local_gap= (1-fraction_women2) - (1-fraction_women1)

*** Share of men in national list-leader positions and the share of men among MPs
gen national_gap1= (1-fraction_women5) - (1-fraction_women3)

*** Share of men in national list-leader positions and the share of women candidates
gen national_gap2= (1-fraction_women5) - (1-fraction_women6)

gen fraction_women1_lag = fraction_women1
replace fraction_women1_lag = fraction_women1[_n-1] if fraction_women1 == .

gen fraction_women2_lag = fraction_women2
replace fraction_women2_lag = fraction_women2[_n-1] if fraction_women2 == .

gen mayor_cand_cascade= fraction_women6 - fraction_women2_lag
gen leader_cab_cascade= fraction_women4 - fraction_women5
gen council_cand_cascade= fraction_women6 - fraction_women1_lag
gen MP_cand_cascade= fraction_women3 - fraction_women6
gen cab_MP_cascade= fraction_women4 - fraction_women3

tw (scatter mayor_cand_cascade year, connect(l) lpattern(solid) lcolor(black) lcolor(gray*0.5) msymbol(circle) mcolor(gray*0.5)) ///
(scatter leader_cab_cascade year,  connect(l) lpattern(solid) lcolor(black) msymbol(triangle) mcolor(gray*0.75)),  ///
xlabel(1920 (5) 2025, labsize(small) angle(45)) plotregion(lcolor(white) ilcolor(white)) graphregion(color(white)) ylabel(,angle(0) gmax) xtitle(Election year) ytitle(Difference in share of positions held by women) ylabel(0(0.1)0.5) scheme(s2mono) legend(order(1 "Candidates vs. Mayors" 2 "Cabinet Ministers vs. List Leaders") pos(10) ring(0) col(1) region(lstyle(none)))  
graph export figures\FigureA4.pdf, replace
